import "./utils/mp-extend/index.js";
App({
  globalData: {
    appid: 'wx0bc7401e920275f0',
    imgUrl: "/image", //图片链接地址,
    uploadsUrl: "https://www.zmg666.com/uploads/zmg",
    apiUrl: "https://www.zmg666.com/api/zmg", //api接口 
    // uploadsUrl: "https://zmg.xywlw.net/uploads/zmg",
    // apiUrl: "https://zmg.xywlw.net/api/zmg", //api接口
    // uploadsUrl: "https://192.168.3.78:7005/uploads/zmg",  
    // apiUrl: "http://192.168.3.5:7005/api/zmg", //api接口 
    permissions: wx.getStorageSync('authorized') || {},
    systemInfo: null, //客户端设备信息 
    memeberText: (wx.getStorageSync('userInfo') && wx.getStorageSync('userInfo').orgType == 2) || (wx.getStorageSync('userInfo') && wx.getStorageSync('userInfo').orgType != 3) ? '合伙人' : '员工'
  },

  getPlatform: function () {
    return this.globalData.systemInfo["platform"]
  },

  getVersion: function () {
    return this.globalData.systemInfo["version"]
  },

  onLaunch: function (options) {
    this.getSystemInfo();
    wx.setStorageSync('uploadUrl', this.globalData.uploadsUrl);
    //请求图片头
    wx.request({
      url: this.globalData.apiUrl + '/sys/comm/file/uploadUrl',
      success: (res) => {
        if (res.data.success) {
          if (res.data.datas.uploadUrl.indexOf('http') > -1) {
            wx.setStorageSync('uploadUrl', res.data.datas.uploadUrl);
          }
        }
      }
    })
    if (!wx.getStorageSync('Authorization')) {
      wx.redirectTo({
        url: '/pages/login/login',
      })
    }
  },


  // 获得设备信息
  getSystemInfo: function () {
    let t = this;
    wx.getSystemInfo({
      success: function (res) {
        t.globalData.systemInfo = res
      },
      fail: function (err) {
        console.log(err)
      }
    });
  },


})